package br.com.fatene.poo2.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import br.com.fatene.poo2.model.User;

public class UserDao {

    private User usuario = new User();

	public User findUser(User user) throws SQLException {
		
		Connection conn = Conexao.obterConexao();
		String sql = "SELECT login FROM usuario WHERE login='"+ user.getLogin() +"' AND senha = '"+ user.getSenha() +"'";
		PreparedStatement stat = conn.prepareStatement(sql);	
		stat.execute();
		if(stat.getResultSet().next()){
			usuario.setLogin(stat.getResultSet().getString(1));
		}
		stat.close();
		conn.close();
		return usuario;
		
	}
	
}
